#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>

using namespace std;

const int N = 2e5 + 5;
int n, m, a[N], b[N];

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    sort(a, a+n), sort(b, b+m);

    int res = INT_MAX;

    int i = 0, j = 0;
    while (i<n && j<n) {
        if (a[i] == b[j]) {
            res = 0;
            break;
        }
        res = min(res, abs(a[i]-b[j]));
        if (a[i]<b[j]) i++;
        else j++;
    }

    cout << res << endl;
    return 0;
}